package com.miaoxun.domain.model;


import com.miaoxun.domain.enums.ErrEnum;

/**
 *@author 小饭
 */
public class ResultModel<T> extends BaseModel {
    private String msg;
    private int code = -1;
    private T data;

    public ResultModel(int code, String msg) {
        this(code, msg, null);
    }

    public ResultModel(int code, T data) {
        this(code, "", data);
    }

    public ResultModel(int code, String msg, T data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    public static ResultModel SUCCESS(int code, String msg, Object data) {
        return new ResultModel(code, msg, data);
    }

    public static ResultModel SUCCESS(int code, String msg) {
        return SUCCESS(code, msg, "");
    }

   public static ResultModel  SUCCESS(ErrEnum errEnum) {
         return SUCCESS(errEnum.getCode(), errEnum.getMsg());
     }
}
